<!-- Load TinyMCE -->
<script type="text/javascript" src="media/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="media/tiny_mce/config.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$("ul.menu li a:contains(วิดิทัศน์)").parent().addClass("active");
	
	$("#add_img").click(function(){
		var form = $("tr:eq(0),tr:eq(1),tr:eq(2),tr:eq(3)").clone();
		form.find("input:text").val("");
		form.find("img").attr("src","themes/tpso1/images/nonpreview.jpg");
		$(".form tr:last").before(form);
		tiny('description');
	});
	
	// $(".inputTextArea").live('keyup', function(e) {
        // var el = $(this);
        // setTimeout(function() {
            // var text = $(el).val();
        	// $.post('vdos/admin/vdos/getThumb',{
        		// 'iframe':text
        	// },function(data){
        		// el.closest("tr").prev().find(".thumb").html(data);
        	// });
        // }, 100);
	// });
	
	var formId = '<?php echo $vdos->id?>';
	if(formId){
		$("#add_img").hide();
	}
});	
</script>

<h1><a href="vdos/admin/categories">วิดิทัศน์</a> » <a href="vdos/admin/vdos/index/<?php echo $categories->id ?>"><?php echo lang_decode($categories->name,'')?></a></h1>
<input id="add_img" type="button" value="เพิ่มรายการ" style="float: left;"><br clear="all"><hr>
<form action="vdos/admin/vdos/save" method="post" enctype="multipart/form-data" id="gallery_form">
<table class="form">
	<tr>
		<th>รูปพรีวิว :</th>
		<td>
			<span class="thumb">
			<?php if($vdos->id):?>
				<?php echo thumb($vdos->cover_pic,180,120,0)?><br>
			<?php endif;?>
			</span>
			<!-- <input type="hidden" name="id[]" value="<?php echo $vdos->id;?>"> --><input type="text" name="cover_pic[]" value="<?php echo $vdos->cover_pic?>"/><input type="button" name="browse" value="เลือกไฟล์" onclick="browser($(this).prev(),'vdo')" />
		</td>
	</tr>
	<tr>
		<th>วีดีโอสคริป :</th>
		<td>
			<? //echo $vdos->vdo_script."<br>";?>
			<textarea class="inputTextArea" name="vdo_script[]"><?php echo $vdos->vdo_script?></textarea>
		</td>
	</tr>
	<tr>
		<th>ชื่อ:</th>
		<td><input type="text" name="title[]" value="<?php echo $vdos->title?>"></td>
	</tr>
	<tr>
		<th>คำอธิบาย:</th>
		<td><input type="text" name="description[]"  value="<?php echo $vdos->description?>"></td>
	</tr>
	<tr>
		<th></th>
		<td>
			<input type="hidden" name="category_id" value="<?php echo $categories->id?>">
			<input type="submit" value="บันทึก">
		</td>
	</tr>
</table>
</form>